1

1.安装

ESLint 是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确、风格统一的代码。

npm install eslint --save-dev

参考资料:eslint官网

2.配置

//package.json

"eslintConfig": {
    //.....
}

3.vue项目配置

  • 1.安装
npm install eslint-plugin-vue -D//-D相当于--save-dev
npm install eslint-plugin-node -D
npm install eslint-config-mysticatea -D
  • 2.配置
//package.json

 "eslintConfig": {
    "root": true,
    "parserOptions": {
      "ecmaVersion": 2017
    },
    "extends": [
      "mysticatea",
      "mysticatea/modules",
      "plugin:vue/recommended"
    ],
    "plugins": [
      "node"
    ],
    "env": {
      "browser": false
    },
    "globals": {
      "applicationCache": false,
      "atob": false,
      "btoa": false,
      "console": false,
      "document": false,
      "location": false,
      "window": false
    },
    "rules": {
      "node/no-extraneous-import": "error",
      "node/no-missing-import": "error",
      "node/no-unpublished-import": "error",
      "vue/html-indent": [
        "error",
        4
      ],
      "vue/max-attributes-per-line": "off",
       "require-noopener": "error"
    }
  },

参考资料:eslint-plugin-vue


stefanieliang
190 声望19 粉丝

一天一笔记~